package api.order;

import com.github.pagehelper.PageInfo;
import dto.Dto;
import dto.ShowWares;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import pojo.*;


import com.github.pagehelper.PageInfo;
import dto.Dto;
import org.springframework.web.bind.annotation.*;
import pojo.BuyOrder;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * 订单模块
 */
@RestController
public interface OrderApi {

    /**
     *订单分页条件查询
     * @param map
     * @return
     */
    @RequestMapping("/selectOrderList")
    Dto<PageInfo<BuyOrder>> selectOrderList( @RequestBody Map<String,Object> map);

    /**
     * 查询用户所有订单
     * @param userId
     * @return
     */
    @RequestMapping("/selectOrderList2")
    List<BuyOrder> selectOrderList2(@RequestParam("userId") Integer userId);


    /**
     * id查看订单详情
     * @param id
     * @return
     */
    @RequestMapping("/selectOrder")
    Dto<BuyOrder> selectOrder(@RequestParam(value = "id") Integer id);

    /**
     * code查看订单详情
     * @param code
     * @return
     */
    @RequestMapping("/selectOrdeCoder")
    BuyOrder selectOrdeCoder(@RequestParam(value = "code") String code);


    /**
     * 修改订单和明细
     * @param buyOrder
     * @return
     */
    @RequestMapping("/updateOrder")
    Integer updateOrder(@RequestBody BuyOrder buyOrder);


    /**
     * 仅仅修改订单2
     */
    @RequestMapping("/updateOrder2")
    Integer updateOrder2(@RequestBody BuyOrder buyOrder);


    /**
     * 订单已收款,减去作废的已收款
     * @param code
     * @param integer
     * @return
     */
    @RequestMapping("/updateOrder3")
    Integer updateOrder3(@RequestParam("code")  String code,@RequestParam("integer") BigDecimal integer);


    /**
     * 修改订单状态
     * @param orderStaId 订单状态
     * @param recStaId 财务状态
     * @param id id
     * @return
     */
    @RequestMapping("/updateOrderState")
    Integer updateOrderState(@RequestParam(value = "orderStaId",required = false) Integer orderStaId,@RequestParam(value = "recStaId",required = false) Integer recStaId,@RequestParam(value = "id",required = false) Integer id);


    /**
     * 新增订单
     * @param buyOrder
     * @return
     */
    @RequestMapping("/insertOrder")
    Integer insertOrder(@RequestBody BuyOrder buyOrder);


    /**
     * (逻辑)删除订单
     * @param id
     * @return
     */
    @RequestMapping("/deleteOrder")
    Integer deleteOrder(@RequestParam(value = "id") Integer id);


    /**
     * (真)删除订单
     * @param code
     * @return
     */
    @RequestMapping("/deleteOrder2")
    Integer deleteOrder2(@RequestParam(value = "code") String code);


// ++++++++++++++++++++++++++++++++++++++++++++++++++++++分割线---------------------------------------

    /**
     * 分页条件查询退货单
     * @param map
     * @return
     */
    @RequestMapping("/selectBuyReturnList")
    Dto<PageInfo<BuyReturn>> selectBuyReturnList(@RequestBody Map<String,Object> map);


    /**
     * id查看退货单详情
     * @param id
     * @return
     */
    @RequestMapping("/selectBuyReturn")
    Dto<BuyReturn> selectBuyReturn(@RequestParam(value = "id") Integer id);


    /**
     * 查看退货单详情
     * @param code
     * @return
     */
    @RequestMapping("/selectBuyReturn2")
    BuyReturn selectBuyReturn2(@RequestParam(value = "code") String code);


    /**
     * 修改退货单
     * @param buyReturn
     * @return
     */
    @RequestMapping("/updateBuyReturn")
    Integer updateBuyReturn(@RequestBody BuyReturn buyReturn);

    /**
     * 修改退货单////订单已付款,减去作废的已付款
     * @param code
     * @param bigDecimal
     * @return
     */
    @RequestMapping("/updateBuyReturn2")
    Integer updateBuyReturn2(@RequestParam(value = "code") String code,@RequestParam("bigDecimal") BigDecimal bigDecimal);

    /**
     * 修改退货单状态
     * @param orderSta 退货单状态
     * @param receSta 付款状态
     * @param id id
     * @return
     */
    @RequestMapping("/updateBuyReturnState")
    Integer updateBuyReturnState(@RequestParam(value = "orderSta",required = false) Integer orderSta,@RequestParam(value = "receSta",required = false) Integer receSta,@RequestParam(value = "id",required = false) Integer id);

    /**
     * 新增退货单
     * @param buyReturn
     * @return
     */
    @RequestMapping("/insertBuyReturn")
    Integer insertBuyReturn(@RequestBody BuyReturn buyReturn);


    /**
     * 逻辑删除退货单
     * @param id
     * @return
     */
    @RequestMapping("/deleteBuyReturn")
    Integer deleteBuyReturn(@RequestParam(value = "id") Integer id);



    /**
     * 根据订单号联合查询商品到 ShowWares 清单对象
     * @param orderId
     * @param type
     * @return
     */
    @RequestMapping("/selectDetailList")
    List<ShowWares> selectDetailList(@RequestParam("orderId") String orderId, @RequestParam("type") Integer type );

    /**
     * 根据退货单号联合查询商品到 ShowWares 清单对象
     * @param orderId
     * @param type
     * @return
     */
    @RequestMapping("/selectDetailList2")
    List<ShowWares> selectDetailList2(@RequestParam("orderId") String orderId, @RequestParam("type") Integer type );


    /**
     * 新增明细表
     * @param detailList
     * @return
     */
    @RequestMapping("/insertDetailList")
    Integer insertDetailList(@RequestBody DetailList detailList);


    /**
     *修改明细表
     * @param detailList
     * @return
     */
    @RequestMapping("/updateDetailList")
    Integer updateDetailList(@RequestBody DetailList detailList);


    /**
     * 删除明细表
     * @param id
     * @return
     */
    @RequestMapping("/deleteDetailList")
    Integer deleteDetailList(@RequestParam("id") Integer id);


    /**
     * 根据退货单id显示退货单页面
     * @param id
     * @return
     */
    @RequestMapping("/seeUpdateBuyReturn")
    Map<String,Object> seeUpdateBuyReturn(@RequestParam("id") Integer id);



    /**
     * 订单明细和商品联合查询
     * @param orderId
     * @return
     */
    @RequestMapping("/detailListWares")
    Map<String,Object> detailListWares(@RequestParam("orderId") String orderId);


//    ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

    /**
     * 根据订单号查出客户
     * @param orderId
     * @return
     */
    @RequestMapping("/orderUser")
    User orderUser(@RequestParam("orderId") Integer orderId);


    /**
     * 批量修改订单明细
     * @return
     */
    @RequestMapping("/updateDetailList2")
    public Integer updateDetailList2(@RequestBody List<DetailList> list);

}
